{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "source": [
    "import re\n",
    "import pandas\n",
    "\n",
    "\n",
    "\n",
    "def apply(repoUrl):\n",
    "  result = {}\n",
    "  repoUrl = repoUrl.replace(' ','')\n",
    "  pattern = r'^https?://gitee\\.com/(?P<userName>[^/]*?)/(?P<repoName>[^/]+?)(\\.git)?$'\n",
    "  m = re.match(pattern, repoUrl,re.M)\n",
    "  if m:\n",
    "    # return m\n",
    "    result['userName'] = m.group('userName')\n",
    "    result['repoName'] = m.group('repoName')\n",
    "    return result\n",
    "  else:\n",
    "    return None"
   ],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "source": [
    "data = pandas.read_csv(\"./2020级广告学专业课程仓库一览表-表格全文.csv\")\n",
    "# print(data)\n",
    "\n",
    "print(data[\"仓库地址\"])"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "0         https://gitee.com/yangjh/web-dev-18ad2.git\n",
      "1                      https:// gitte.com/yujiao2001\n",
      "2     https://gitee.com/jiangzhongcheng2020/jzc-20-2\n",
      "3        https://gitee.com/ranxiaojun/ranxiaojun.git\n",
      "4        https://gitee.com/xiapingqin/xiapingqin.git\n",
      "                           ...                      \n",
      "94                https://gitee.com/zhouluan/kry.git\n",
      "95               https://gitee.com/dmnweixixi/cc.git\n",
      "96          https://gitee.com/ranxiyi/songyaxuan.git\n",
      "97        https://gitee.com/wanghaiyan644534/why.git\n",
      "98             https://gitee.com/sitd8/long-sang.git\n",
      "Name: 仓库地址, Length: 99, dtype: object\n"
     ]
    }
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "source": [
    "data[\"是否正确\"] = data[\"仓库地址\"].apply(apply)"
   ],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "source": [
    "print(data)"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "            学号   姓名                                            仓库地址  \\\n",
      "0   P201212128  马玉兰      https://gitee.com/yangjh/web-dev-18ad2.git   \n",
      "1   P201212156   余娇                   https:// gitte.com/yujiao2001   \n",
      "2   P201212357  江中诚  https://gitee.com/jiangzhongcheng2020/jzc-20-2   \n",
      "3   P201212161  冉小军     https://gitee.com/ranxiaojun/ranxiaojun.git   \n",
      "4   P201212129  夏平琴     https://gitee.com/xiapingqin/xiapingqin.git   \n",
      "..         ...  ...                                             ...   \n",
      "94  P201212092   周銮              https://gitee.com/zhouluan/kry.git   \n",
      "95  P201212084  韦茜茜             https://gitee.com/dmnweixixi/cc.git   \n",
      "96  P201212120  冉西谊        https://gitee.com/ranxiyi/songyaxuan.git   \n",
      "97  P201212114  王海燕      https://gitee.com/wanghaiyan644534/why.git   \n",
      "98  P201212078  郭善鑫           https://gitee.com/sitd8/long-sang.git   \n",
      "\n",
      "                                                 是否正确  \n",
      "0   {'userName': 'yangjh', 'repoName': 'web-dev-18...  \n",
      "1                                                None  \n",
      "2   {'userName': 'jiangzhongcheng2020', 'repoName'...  \n",
      "3   {'userName': 'ranxiaojun', 'repoName': 'ranxia...  \n",
      "4   {'userName': 'xiapingqin', 'repoName': 'xiapin...  \n",
      "..                                                ...  \n",
      "94        {'userName': 'zhouluan', 'repoName': 'kry'}  \n",
      "95       {'userName': 'dmnweixixi', 'repoName': 'cc'}  \n",
      "96  {'userName': 'ranxiyi', 'repoName': 'songyaxuan'}  \n",
      "97  {'userName': 'wanghaiyan644534', 'repoName': '...  \n",
      "98     {'userName': 'sitd8', 'repoName': 'long-sang'}  \n",
      "\n",
      "[99 rows x 4 columns]\n"
     ]
    }
   ],
   "metadata": {}
  }
 ],
 "metadata": {
  "orig_nbformat": 4,
  "language_info": {
   "name": "python",
   "version": "3.9.7",
   "mimetype": "text/x-python",
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "pygments_lexer": "ipython3",
   "nbconvert_exporter": "python",
   "file_extension": ".py"
  },
  "kernelspec": {
   "name": "python3",
   "display_name": "Python 3.9.7 64-bit"
  },
  "interpreter": {
   "hash": "aee8b7b246df8f9039afb4144a1f6fd8d2ca17a180786b69acc140d282b71a49"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}